<?php
//echo "<pre>";
//print_r($_POST);
//echo "</pre>";
@ob_start();
@session_start();
require_once("../../../includes/GPSFunction.php");

//require("checkSession.php");
error_reporting (E_ALL ^ E_NOTICE);	
//	USER OR SUPERADMIN SESSION CHECK
if(isset($_SESSION[superID]))
	require("../../sa/checkSession.php");
elseif(isset($_SESSION[userID]) && isset($_SESSION[clientID]))
	require("../../user/checkSession.php");
//exit;

require("../../../includes/config.inc.php"); 
require("../../../includes/Database.class.php"); 

$db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); 
$db->connect(); 

$getUserInfo = "SELECT * FROM tb_userinfo,tb_clientinfo WHERE ui_id  = ".$_SESSION[userID]." AND ci_id = ".$_SESSION[clientID];
$resUserInfo = $db->query($getUserInfo);

if($db->affected_rows > 0){
	$recordUserInfo = $db->fetch_array($resUserInfo);
	//print_r($recordUserInfo);	
	if($recordUserInfo[ci_clientId]!=0)
	{
		$getResellInfo = "SELECT ci_clientName,ci_clientLogo,ci_footerText FROM tb_clientinfo WHERE ci_id = ".$recordUserInfo[ci_clientId];
		$resResellInfo = $db->query($getResellInfo);
		if($db->affected_rows > 0){
			$fetResellInfo = $db->fetch_array($resResellInfo);
			$clientLogo = $fetResellInfo[ci_clientLogo];
			$clientOrgName = $fetResellInfo[ci_clientName];
			$clientFooter = $fetResellInfo[ci_footerText];
		}
		else
		{
			$clientOrgName = $recordUserInfo[ci_clientName];
			$clientLogo = $recordUserInfo[ci_clientLogo];
			$clientFooter = $recordUserInfo[ci_footerText];
		}
	}
	else
	{
		$clientOrgName = $recordUserInfo[ci_clientName];
		$clientLogo = $recordUserInfo[ci_clientLogo];
		$clientFooter = $recordUserInfo[ci_footerText];
	}
	$welcomeTxt = '';
	if($recordUserInfo[ui_isAdmin] == 1)
	{
		$welcomeTxt = 'Admin';
	}
	elseif($recordUserInfo[ui_roleId])
	{
		
		$welcomeTxt = $util->getRoleNameOfUserByRoleId($recordUserInfo[ui_roleId]);
	}
	
}

if(isset($_POST[date_offline]) && $_POST[date_offline])
	$date_offline = $_POST[date_offline];
else
	$date_offline = date('d-m-Y');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $clientOrgName;?> :: GPS Application</title>
<link href="../../../images/fav-icon.gif" rel="icon" />

<link href="../../../css/style.css" rel="stylesheet" type="text/css" />
<link href="../css/mapCss.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../../../css/themes/base/jquery.ui.all.css">
<script language="javascript" src="../javascript/ajax.js"></script>

<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=<?php echo GOOGLE_API_KEY;?>" type="text/javascript"></script>

<script src="../../../js/jquery-1.4.2.js"></script>
<script src="../../../js/ui/jquery.ui.core.js"></script>
<script src="../../../js/ui/jquery.ui.widget.js"></script>

<script type="text/javascript" src="../js/jquery.layout.js"></script>

<script src="js/geopoly.js" type="text/javascript"></script>

<style type="text/css">
  @import url("gsearch.css");
  @import url("gmlocalsearch.css");


.ui-layout-pane { /* all 'panes' */ 
	background: #FFF; 
	border: 1px solid #BBB; 
	padding: 10px; 
	overflow: auto;
} 

.ui-layout-resizer { /* all 'resizer-bars' */ 
	background: #DDD; 
} 

.ui-layout-toggler { /* all 'toggler-buttons' */ 
	background: #AAA; 
} 
</style>
<style type="text/css">
body {
  font-family: Arial, sans serif;
  font-size: 11px;
}
#hand_b {
  width:31px;
  height:31px;
  background-image: url(http://google.com/mapfiles/ms/t/Bsu.png);
}
#hand_b.selected {
  background-image: url(http://google.com/mapfiles/ms/t/Bsd.png);
}

#placemark_b {
  width:31px;
  height:31px;
  background-image: url(http://google.com/mapfiles/ms/t/Bmu.png);
}
#placemark_b.selected {
  background-image: url(http://google.com/mapfiles/ms/t/Bmd.png);
}

#line_b {
  width:31px;
  height:31px;
  background-image: url(http://google.com/mapfiles/ms/t/Blu.png);
}
#line_b.selected {
  background-image: url(http://google.com/mapfiles/ms/t/Bld.png);
}

#shape_b {
  width:31px;
  height:31px;
  background-image: url(http://google.com/mapfiles/ms/t/Bpu.png);
}
#shape_b.selected {
  background-image: url(http://google.com/mapfiles/ms/t/Bpd.png);
}
</style>
<script type="text/javascript">
var myLayout; // a var is required because this page utilizes: myLayout.allowOverflow() method

$(document).ready(function () {
	myLayout = $('body').layout({
		// enable showOverflow on west-pane so popups will overlap north pane
		west__showOverflowOnHover: true

	//,	west__fxSettings_open: { easing: "easeOutBounce", duration: 750 }
	});
});
initMenu();
function initMenu() {
	
  $('#menu ul').hide();
  $('#menu ul:first').show();
  $('#menu li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#menu ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }

//]]>
</script>

</head>

<body onload="initialize()" onunload="GUnload">

<div class="ui-layout-north">
<div class="headerarea"><!-- Headerarea div START here -->
    	<div class="toparea"><!-- toparea div start here -->
        	<div style="float:left"><a href="?ch=home"><img src="../../client_logo/<?php echo $clientLogo;?>" width="175" height="55" /></a></div>

            <div class="ui-widget-header">               
                <p class="" id="messages">Loading...</p>
            </div>
            
            
        <div class="clear"></div>    
        </div><!-- toparea div END here -->
        
    </div>
</div>

<div class="ui-layout-west">
<input type="text" id="featuredetails" rows="2" />
<table width="100%" cols="1">
    <tr>
        <td style="display:none"><div id="hand_b"
	 onclick="stopEditing()"/></td>
<td style="display:none"><div id="placemark_b"
	 onclick="placeMarker()"/></td>
<td style="display:none"><div id="line_b"
	 onclick="startLine()"/></td>
<td>Pick this to create polygon <div id="shape_b"
	onclick="startShape()"/></td>

    </tr>
    <tr>
    <td colspan="4" id="frame"></td>
    </tr>
    <tr>
    <td colspan="4">
        <ul id="menu3" style="-moz-user-select: none;  position: absolute; left: 50px; top: 10px;">
        
        </ul>
    </td>
    </tr>
</table>
<table id ="featuretable">
     <tbody id="featuretbody"></tbody>
</table>
</div>

<div class="ui-layout-center" id="map_canvas">Loading...</div>
</div>
	<div class="footerarea" style="display:none;"><!-- footerarea div START here -->
    	<span class="left"><?php echo $clientFooter;?></span>
        <span class="right" style="text-align:right;"><!--<a href="#">Link one</a> | <a href="#">Link one</a> | <a href="#">Terms &amp; Conditions</a>--></span>
    </div>

</body>
</html>
